package top.jiangqiang.qyblog.core.handler;

import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import top.jiangqiang.qyblog.common.utils.JSONUtil;

/**
 * @author JiangQiang
 */
@Slf4j
@MappedTypes({Object.class})
@MappedJdbcTypes(JdbcType.VARCHAR)
public class JacksonTypeHandler extends AbstractJsonTypeHandler<Object> {

    @Override
    protected Object parse(String json) {
        return JSONUtil.parse(json);
    }

    @Override
    protected String toJson(Object obj) {
        return JSONUtil.toJsonStrWithClass(obj);
    }

}
